package web_k;

import pojo_k.HomeUser;
import service_k.HomeUserService;
import service_k.MainUserService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/mainUserDeleteServlet")
public class MainUserDeleteServlet extends HttpServlet {
    private MainUserService service = new MainUserService();
    private HomeUserService service1 = new HomeUserService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String homeuserName = request.getParameter("homeuserName");

        service.mainUserDelete(homeuserName);

        HomeUser homeUser = service1.homeUserSelectByName(homeuserName);

        if (homeUser == null) {
            response.setContentType("text/html;charset=utf-8");
            response.getWriter().write("该用户已被删除");
        } else {
            response.setContentType("text/html;charset=utf-8");
            response.getWriter().write("删除失败，请您再次尝试删除");
        }


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
